package com.woniuxy01;

import java.io.File;
import java.io.IOException;

/**
 * @author 作者
 * @create 2025-07-31 16:42
 */
public class Test03 {
    public static void main(String[] args) throws IOException {
        File file1 = new File("D:\\aaa");
        String[] list = file1.list();
        for(String s : list){
            System.out.println(s);
        }

        File[] files = file1.listFiles();
        for(File file : files){
            System.out.println(file.getAbsolutePath());
        }
    }

    private static void test04() throws IOException {
        File file = new File("d:\\aaa\\b.txt");
        //创建文件
        file.createNewFile();
    }

    private static void test03() {
        File file = new File("d:\\aaa\\d\\d1\\d2");
        //创建目录,上级目录必须存在
//        System.out.println(file.mkdir());
        //上级目录，不存在会自动创建
        System.out.println(file.mkdirs());
    }

    private static void test02() {
        File file1 = new File("D:\\aaa","a");
        System.out.println(file1.getPath());
        System.out.println(file1.getAbsolutePath());
        System.out.println(file1.getName());
    }

    private static void test01() {
        File file1 = new File("D:\\aaa");
        File file2 = new File("D:\\aaa\\a.txt");
        System.out.println(file1.isFile());
        System.out.println(file1.isDirectory());
        System.out.println(file2.isFile());
        System.out.println(file2.isDirectory());
        System.out.println(new File("D:\\aaa").exists() );
        System.out.println(new File("D:\\bbb").exists() );
    }
}
